package scalab.core

trait Recipient extends Buildable{
	import scalab.core.component.{Component, Universe}
	import scala.collection.immutable.HashSet
	import scalab.core.dependencies.Dependency

	val component: Component

	def providers: List[Component]
	final def hasUniverse: Boolean = providers exists {p => p == Universe}
	def sources: Iterable[Dependency]
	final def orderedSources = Dependency.orderDependencies(sources)
	final def sourceSet = HashSet.empty[Dependency] ++ sources

	def outOfDateSources: Set[Dependency]

	def invalidate(dep: Dependency): Recipient
	def invalidate(deps: Iterable[Dependency]): Recipient
	final def invalidateSources: Recipient = invalidate(sources)

	def lackingSources: List[Dependency]

	final def <<(ps: Iterable[Provider]): Unit = {
		ps foreach {p => p->this}
	}

	final def <<(ps: Provider*): Unit = <<(ps)

	
}
